<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义全局指令——自动获得输入焦点</title>
</head>
<body>
<div id="app">
    <label for="wd">
        请输入要搜索的内容
        <input type="text" name="wd" v-focus>
    </label>
</div>

<script type="module">
    import {createApp} from "../../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {

            }
        }
    )

    app.directive(
        "focus",
        {
            // el 当前指令所在的元素
            // binding 传入的值
            mounted(el, binding){
                el.focus()
            }
        }
    )

    app.mount("#app")
</script>
</body>
</html>